﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using QualityRpt.Utils;
using System.Data.Odbc;
using Org.SqlHelper;

namespace QualityRpt.Dao.Db2
{
    class RPTResultDao:IRPTResultDao
    {
        public DataTable GetTempSchema()
        {
            return GetTempList("ID=0").Clone();
        }
        public DataRow SaveTemplate(DataRow row)
        {
            object rt = null;
            using (OdbcConnection conn = ODBCHelper.GetConnection())
            {
                ODBCHelper.ExecuteNonQuery(conn, CommandType.Text,
                "INSERT INTO RPT.RPT_TEMPLATE(DEVICE_ID,TEMP_NAME,START_TIME,END_TIME,STAT_Y2Y,STAT_M2M,STAT_TTYPE,FROM_TEMP,STAT_UNREAD,WORK_MODE,STAT_INDIC,STAT_GROUP,TIME_TYPE,TIME_DATE,DATA_STATUS) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
                    ODBCHelper.CreateInputParameter("DEVICE_ID", OdbcType.Int, Convert.ToInt32(row["DEVICE_ID"])),
                    ODBCHelper.CreateInputParameter("TEMP_NAME", OdbcType.VarChar, 200, row["TEMP_NAME"]),
                    ODBCHelper.CreateInputParameter("START_TIME", OdbcType.DateTime, row["START_TIME"]),
                    ODBCHelper.CreateInputParameter("END_TIME", OdbcType.DateTime, row["END_TIME"]),
                    ODBCHelper.CreateInputParameter("STAT_Y2Y", OdbcType.SmallInt, row["STAT_Y2Y"]),
                    ODBCHelper.CreateInputParameter("STAT_M2M", OdbcType.SmallInt, row["STAT_M2M"]),
                    ODBCHelper.CreateInputParameter("STAT_TTYPE", OdbcType.SmallInt, row["STAT_TTYPE"]),
                    ODBCHelper.CreateInputParameter("FROM_TEMP", OdbcType.SmallInt, row["FROM_TEMP"]),
                    ODBCHelper.CreateInputParameter("STAT_UNREAD", OdbcType.SmallInt, row["STAT_UNREAD"]),
                    ODBCHelper.CreateInputParameter("WORK_MODE", OdbcType.Text,  row["WORK_MODE"]),
                    ODBCHelper.CreateInputParameter("STAT_INDIC", OdbcType.Text, row["STAT_INDIC"]),
                    ODBCHelper.CreateInputParameter("STAT_GROUP", OdbcType.Text, row["STAT_GROUP"]),
                    ODBCHelper.CreateInputParameter("TIME_TYPE", OdbcType.SmallInt, row["TIME_TYPE"]),
                    ODBCHelper.CreateInputParameter("TIME_DATE", OdbcType.VarChar, 50, row["TIME_DATE"]),
                    ODBCHelper.CreateInputParameter("DATA_STATUS", OdbcType.SmallInt, row["DATA_STATUS"])
                    );
                rt = ODBCHelper.ExecuteScalar(conn, CommandType.Text, "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1");
            }
            if (rt != DBNull.Value)
            {
                row["ID"] = Convert.ToInt32(rt);
                return row;
            }
            return null;
        }
        public DataRow UpdateTemplate(DataRow row)
        {
            using (OdbcConnection conn = ODBCHelper.GetConnection())
            {
                ODBCHelper.ExecuteNonQuery(conn, CommandType.Text,
                "UPDATE RPT.RPT_TEMPLATE SET DEVICE_ID=?,TEMP_NAME=?,START_TIME=?,END_TIME=?,STAT_Y2Y=?,STAT_M2M=?,STAT_TTYPE=?,FROM_TEMP=?,STAT_UNREAD=?,WORK_MODE=?,STAT_INDIC=?,STAT_GROUP=?,TIME_TYPE=?,TIME_DATE=?,DATA_STATUS=? WHERE ID=?",
                    ODBCHelper.CreateInputParameter("DEVICE_ID", OdbcType.Int, Convert.ToInt32(row["DEVICE_ID"])),
                    ODBCHelper.CreateInputParameter("TEMP_NAME", OdbcType.VarChar, 200, row["TEMP_NAME"]),
                    ODBCHelper.CreateInputParameter("START_TIME", OdbcType.DateTime, row["START_TIME"]),
                    ODBCHelper.CreateInputParameter("END_TIME", OdbcType.DateTime, row["END_TIME"]),
                    ODBCHelper.CreateInputParameter("STAT_Y2Y", OdbcType.SmallInt, row["STAT_Y2Y"]),
                    ODBCHelper.CreateInputParameter("STAT_M2M", OdbcType.SmallInt, row["STAT_M2M"]),
                    ODBCHelper.CreateInputParameter("STAT_TTYPE", OdbcType.SmallInt, row["STAT_TTYPE"]),
                    ODBCHelper.CreateInputParameter("FROM_TEMP", OdbcType.SmallInt, row["FROM_TEMP"]),
                    ODBCHelper.CreateInputParameter("STAT_UNREAD", OdbcType.SmallInt, row["STAT_UNREAD"]),
                    ODBCHelper.CreateInputParameter("WORK_MODE", OdbcType.Text, row["WORK_MODE"]),
                    ODBCHelper.CreateInputParameter("STAT_INDIC", OdbcType.Text,  row["STAT_INDIC"]),
                    ODBCHelper.CreateInputParameter("STAT_GROUP", OdbcType.Text, row["STAT_GROUP"]),
                    ODBCHelper.CreateInputParameter("TIME_TYPE", OdbcType.SmallInt, row["TIME_TYPE"]),
                    ODBCHelper.CreateInputParameter("TIME_DATE", OdbcType.VarChar, 50, row["TIME_DATE"]),
                    ODBCHelper.CreateInputParameter("DATA_STATUS", OdbcType.SmallInt, row["DATA_STATUS"]),
                    ODBCHelper.CreateInputParameter("ID", OdbcType.Int, Convert.ToInt32(row["ID"]))
                    );
            }
            return row;
        }
        public void DelTemplate(int id)
        {
            DataRow tempRow = GetTemplate(id);
            tempRow["DATA_STATUS"] = -1;
            UpdateTemplate(tempRow);
        }
        public DataTable GetTempMetaSchema()
        {
            return GetTempMetaList("ID=0", string.Empty).Clone();
        }
        public DataTable GetTempMetaList(string where,string sort)
        {
            StringBuilder sbText = new StringBuilder();
            sbText.Append("SELECT * FROM RPT.TEMPLATE_META ");
            if (where.Trim() != string.Empty)
            {
                sbText.Append(" WHERE " + where);
            }
            if (sort.Trim() != string.Empty)
            {
                sbText.Append(" ORDER BY " + sort);
            }
            using (OdbcConnection conn = ODBCHelper.GetConnection())
            {
                return ODBCHelper.ReadTable(conn, CommandType.Text, sbText.ToString());
            }
        }
        public DataTable SaveTempMeta(int temp_id,DataTable metaTable)
        {
            using (OdbcConnection conn = ODBCHelper.GetConnection())
            {
                for (int i = 0; i < metaTable.Rows.Count; i++)
                {
                    DataRow row = metaTable.Rows[i];
                    row["TEMPLATE_ID"] = temp_id;
                    object rt = null;
                    ODBCHelper.ExecuteNonQuery(conn, CommandType.Text,
                    "INSERT INTO RPT.TEMPLATE_META(TEMPLATE_ID,META_GROUP,META_KEY,META_SYMBOL,META_VALUE) VALUES(?,?,?,?,?)",
                        ODBCHelper.CreateInputParameter("TEMPLATE_ID", OdbcType.Int, Convert.ToInt32(row["TEMPLATE_ID"])),
                        ODBCHelper.CreateInputParameter("META_GROUP", OdbcType.SmallInt, row["META_GROUP"]),
                        ODBCHelper.CreateInputParameter("META_KEY", OdbcType.VarChar, 50, row["META_KEY"]),
                        ODBCHelper.CreateInputParameter("META_SYMBOL", OdbcType.VarChar, 20, row["META_SYMBOL"]),
                        ODBCHelper.CreateInputParameter("META_VALUE", OdbcType.Text, row["META_VALUE"])
                        );
                    rt = ODBCHelper.ExecuteScalar(conn, CommandType.Text, "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1");
                    if (rt != DBNull.Value)
                    {
                        row["ID"] = Convert.ToInt32(rt);
                    }
                }
                return metaTable;
            }
        }
        public void UpdateTempMeta(int temp_id,DataTable metaTable)
        {
            using (OdbcConnection conn = ODBCHelper.GetConnection())
            {
                ODBCHelper.ExecuteNonQuery(conn, CommandType.Text, "DELETE FROM RPT.TEMPLATE_META WHERE TEMPLATE_ID=" + temp_id.ToString());
            }
            SaveTempMeta(temp_id,metaTable);
        }
        public DataTable GetTempList(string where)
        {
            return GetTempList(where,string.Empty);
        }
        public DataTable GetTempList(string where, string sort)
        {
            StringBuilder sbText = new StringBuilder();
            sbText.Append("SELECT * FROM RPT.RPT_TEMPLATE ");
            if (where.Trim() != string.Empty)
            {
                sbText.Append(" WHERE " + where);
            }
            if (sort.Trim() != string.Empty)
            {
                sbText.Append(" ORDER BY " + sort);
            }
            using (OdbcConnection conn = ODBCHelper.GetConnection())
            {
                return ODBCHelper.ReadTable(conn, CommandType.Text, sbText.ToString());
            }
        }
        public DataTable GetTempPageList(PageUtils pu, string where, string sort)
        {
            StringBuilder sbCountSql = new StringBuilder();
            StringBuilder sbListSql = new StringBuilder();
            sbCountSql.Append("SELECT COUNT(*) FROM RPT.RPT_TEMPLATE AS T");
            sbListSql.Append("SELECT T.* FROM RPT.RPT_TEMPLATE AS T");
            if (where.Trim() != string.Empty)
            {
                sbCountSql.Append(" WHERE " + where);
                sbListSql.Append(" WHERE " + where);
            }
            if (sort.Trim() != string.Empty)
            {
                sbListSql.Append(" ORDER BY " + sort);
            }
            else
            {
                sbListSql.Append(" ORDER BY ID DESC");
            }
            pu.TotalCountSql = sbCountSql.ToString();
            pu.ListSql = sbListSql.ToString();
            return pu.GetDb2OdbcPageList();
        }
        
        public DataTable GetList(string where)
        {
            return GetList(where, string.Empty);
        }
        public DataTable GetList(string where, string sort)
        {
            StringBuilder sbText = new StringBuilder();
            sbText.Append("SELECT * FROM RPT.RPT_RESULT ");
            if (where.Trim() != string.Empty)
            {
                sbText.Append(" WHERE " + where);
            }
            if (sort.Trim() != string.Empty)
            {
                sbText.Append(" ORDER BY " + sort);
            }
            using (OdbcConnection conn = ODBCHelper.GetConnection())
            {
                return ODBCHelper.ReadTable(conn, CommandType.Text, sbText.ToString());
            }
        }
        public DataTable GetPageList(PageUtils pu, string where, string sort)
        {
            StringBuilder sbCountSql = new StringBuilder();
            StringBuilder sbListSql = new StringBuilder();
            sbCountSql.Append("SELECT COUNT(*) FROM RPT.RPT_RESULT ");
            sbListSql.Append("SELECT * FROM RPT.RPT_RESULT ");
            if (where.Trim() != string.Empty)
            {
                sbCountSql.Append(" WHERE " + where);
                sbListSql.Append(" WHERE " + where);
            }
            if (sort.Trim() != string.Empty)
            {
                sbListSql.Append(" ORDER BY " + sort);
            }
            else
            {
                sbListSql.Append(" ORDER BY ID DESC");
            }
            pu.TotalCountSql = sbCountSql.ToString();
            pu.ListSql = sbListSql.ToString();
            return pu.GetDb2OdbcPageList();
        }
        public void DeleteByJobID(int job_id)
        {
            using (OdbcConnection conn = ODBCHelper.GetConnection())
            {
                ODBCHelper.ExecuteNonQuery(conn, CommandType.Text, "DELETE FROM RPT.RPT_RESULT WHERE JOB_ID=?",
                    ODBCHelper.CreateInputParameter("ID", OdbcType.Int, job_id));
            }
        }
        public DataTable GetByJobID(int job_id)
        {
            return GetList("JOB_ID = "+job_id.ToString());
        }

        public DataRow GetTemplate(int id)
        {
            DataTable rtTable = GetTempList("ID="+id);
            if (rtTable.Rows.Count > 0)
            {
                return rtTable.Rows[0];
            }
            return null;
        }

        public DataTable GetTempMetaList(int temp_id)
        {
            return GetTempMetaList("TEMPLATE_ID=" + temp_id, string.Empty);
        }

        public DataRow Save(DataRow row)
        {
            throw new NotImplementedException();
        }

        public DataRow Update(DataRow row)
        {
            throw new NotImplementedException();
        }

        public DataRow Get(long id)
        {
            throw new NotImplementedException();
        }

        public void Delete(long id)
        {
            throw new NotImplementedException();
        }
        public DataTable Save(int job_id, DataTable result_table)
        {
            for (int i = 0; i < result_table.Rows.Count; i++)
            {
                DataRow row = result_table.Rows[i];
                row["JOB_ID"] = job_id;
                object rt = null;
                using (OdbcConnection conn = ODBCHelper.GetConnection())
                {
                    ODBCHelper.ExecuteNonQuery(conn, CommandType.Text,
                    "INSERT INTO RPT.RPT_RESULT(JOB_ID,SUPPLIER_NAME,SPEC_NAME,AIRWIRE_SUPPLIER_NAME,AIRWIRE_SPEC_NAME,CONTRACT_NO,ROAD_NAME,PLAZA_NAME,LANE_NO,ICARD_WORKMODE"
                    + ",STYEAR,STMONTH,STWEEK,STDAY,STHOUR,TRANSCOUNT,TRANSDCOUNT,ONEPASS_TRANSCOUNT,DEVSUC_TRANSCOUNT,DEVEX_TRANSCOUNT,LEX_TRANSCOUNT,TAMP_TRANSCOUNT,LB_TRANSCOUNT"
                    + ",UNREAD_TRANSCOUNT,MODE_TRANSCOUNT,Y2YTRANSCOUNT,Y2YTRANSDCOUNT,Y2YONEPASS_TRANSCOUNT,Y2YDEVSUC_TRANSCOUNT,Y2YDEVEX_TRANSCOUNT,Y2YLEX_TRANSCOUNT,Y2YTAMP_TRANSCOUNT"
                    + ",Y2YLB_TRANSCOUNT,Y2YUNREAD_TRANSCOUNT,Y2YMODE_TRANSCOUNT,M2MTRANSCOUNT,M2MTRANSDCOUNT,M2MONEPASS_TRANSCOUNT,M2MDEVSUC_TRANSCOUNT,M2MDEVEX_TRANSCOUNT,M2MLEX_TRANSCOUNT"
                    + ",M2MTAMP_TRANSCOUNT,M2MLB_TRANSCOUNT,M2MUNREAD_TRANSCOUNT,M2MMODE_TRANSCOUNT,ONEPASS_RATE,DEVSUC_RATE,DEVEX_RATE,LEX_RATE,TAMP_RATE,LB_RATE,UNREAD_RATE,MODE_RATE,Y2YONEPASS_RATE,Y2YDEVSUC_RATE"
                    + ",Y2YDEVEX_RATE,Y2YLEX_RATE,Y2YTAMP_RATE,Y2YLB_RATE,Y2YUNREAD_RATE,Y2YMODE_RATE,M2MONEPASS_RATE,M2MDEVSUC_RATE,M2MDEVEX_RATE,M2MLEX_RATE,M2MTAMP_RATE,M2MLB_RATE,M2MUNREAD_RATE,M2MMODE_RATE)"
                    + " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
                        ODBCHelper.CreateInputParameter("JOB_ID", OdbcType.Int, Convert.ToInt32(row["JOB_ID"])),
                        ODBCHelper.CreateInputParameter("SUPPLIER_NAME", OdbcType.VarChar, 50, row["SUPPLIER_NAME"]),
                        ODBCHelper.CreateInputParameter("SPEC_NAME", OdbcType.VarChar, 50, row["SPEC_NAME"]),
                        ODBCHelper.CreateInputParameter("AIRWIRE_SUPPLIER_NAME", OdbcType.VarChar, 50, row["AIRWIRE_SUPPLIER_NAME"]),
                        ODBCHelper.CreateInputParameter("AIRWIRE_SPEC_NAME", OdbcType.VarChar, 50, row["AIRWIRE_SPEC_NAME"]),
                        ODBCHelper.CreateInputParameter("CONTRACT_NO", OdbcType.VarChar, 50, row["CONTRACT_NO"]),
                        ODBCHelper.CreateInputParameter("ROAD_NAME", OdbcType.VarChar, 50, row["ROAD_NAME"]),
                        ODBCHelper.CreateInputParameter("PLAZA_NAME", OdbcType.VarChar, 50, row["PLAZA_NAME"]),
                        ODBCHelper.CreateInputParameter("LANE_NO", OdbcType.SmallInt, row["LANE_NO"]),
                        ODBCHelper.CreateInputParameter("ICARD_WORKMODE", OdbcType.SmallInt, row["ICARD_WORKMODE"]),
                        ODBCHelper.CreateInputParameter("STYEAR", OdbcType.Int, row["STYEAR"]),
                        ODBCHelper.CreateInputParameter("STMONTH", OdbcType.Int, row["STMONTH"]),
                        ODBCHelper.CreateInputParameter("STWEEK", OdbcType.Int, row["STWEEK"]),
                        ODBCHelper.CreateInputParameter("STDAY", OdbcType.Int, row["STDAY"]),
                        ODBCHelper.CreateInputParameter("STHOUR", OdbcType.Int, row["STHOUR"]),
                        ODBCHelper.CreateInputParameter("TRANSCOUNT", OdbcType.Int, row["TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("TRANSDCOUNT", OdbcType.Int, row["TRANSDCOUNT"]),
                        ODBCHelper.CreateInputParameter("ONEPASS_TRANSCOUNT", OdbcType.Int, row["ONEPASS_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("DEVSUC_TRANSCOUNT", OdbcType.Int, row["DEVSUC_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("DEVEX_TRANSCOUNT", OdbcType.Int, row["DEVEX_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("LEX_TRANSCOUNT", OdbcType.Int, row["LEX_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("TAMP_TRANSCOUNT", OdbcType.Int, row["TAMP_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("LB_TRANSCOUNT", OdbcType.Int, row["LB_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("UNREAD_TRANSCOUNT", OdbcType.Int, row["UNREAD_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("MODE_TRANSCOUNT", OdbcType.Int, row["MODE_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YTRANSCOUNT", OdbcType.Int, row["Y2YTRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YTRANSDCOUNT", OdbcType.Int, row["Y2YTRANSDCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YONEPASS_TRANSCOUNT", OdbcType.Int, row["Y2YONEPASS_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YDEVSUC_TRANSCOUNT", OdbcType.Int, row["Y2YDEVSUC_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YDEVEX_TRANSCOUNT", OdbcType.Int, row["Y2YDEVEX_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YLEX_TRANSCOUNT", OdbcType.Int, row["Y2YLEX_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YTAMP_TRANSCOUNT", OdbcType.Int, row["Y2YTAMP_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YLB_TRANSCOUNT", OdbcType.Int, row["Y2YLB_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YUNREAD_TRANSCOUNT", OdbcType.Int, row["Y2YUNREAD_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("Y2YMODE_TRANSCOUNT", OdbcType.Int, row["Y2YMODE_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MTRANSCOUNT", OdbcType.Int, row["M2MTRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MTRANSDCOUNT", OdbcType.Int, row["M2MTRANSDCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MONEPASS_TRANSCOUNT", OdbcType.Int, row["M2MONEPASS_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MDEVSUC_TRANSCOUNT", OdbcType.Int, row["M2MDEVSUC_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MDEVEX_TRANSCOUNT", OdbcType.Int, row["M2MDEVEX_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MLEX_TRANSCOUNT", OdbcType.Int, row["M2MLEX_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MTAMP_TRANSCOUNT", OdbcType.Int, row["M2MTAMP_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MLB_TRANSCOUNT", OdbcType.Int, row["M2MLB_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MUNREAD_TRANSCOUNT", OdbcType.Int, row["M2MUNREAD_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("M2MMODE_TRANSCOUNT", OdbcType.Int, row["M2MMODE_TRANSCOUNT"]),
                        ODBCHelper.CreateInputParameter("ONEPASS_RATE", OdbcType.Decimal, row["ONEPASS_RATE"]),
                        ODBCHelper.CreateInputParameter("DEVSUC_RATE", OdbcType.Decimal, row["DEVSUC_RATE"]),
                        ODBCHelper.CreateInputParameter("DEVEX_RATE", OdbcType.Decimal, row["DEVEX_RATE"]),
                        ODBCHelper.CreateInputParameter("LEX_RATE", OdbcType.Decimal, row["LEX_RATE"]),
                        ODBCHelper.CreateInputParameter("TAMP_RATE", OdbcType.Decimal, row["TAMP_RATE"]),
                        ODBCHelper.CreateInputParameter("LB_RATE", OdbcType.Decimal, row["LB_RATE"]),
                        ODBCHelper.CreateInputParameter("UNREAD_RATE", OdbcType.Decimal, row["UNREAD_RATE"]),
                        ODBCHelper.CreateInputParameter("MODE_RATE", OdbcType.Decimal, row["MODE_RATE"]),
                        ODBCHelper.CreateInputParameter("Y2YONEPASS_RATE", OdbcType.Decimal, row["Y2YONEPASS_RATE"]),
                        ODBCHelper.CreateInputParameter("Y2YDEVSUC_RATE", OdbcType.Decimal, row["Y2YDEVSUC_RATE"]),
                        ODBCHelper.CreateInputParameter("Y2YDEVEX_RATE", OdbcType.Decimal, row["Y2YDEVEX_RATE"]),
                        ODBCHelper.CreateInputParameter("Y2YLEX_RATE", OdbcType.Decimal, row["Y2YLEX_RATE"]),
                        ODBCHelper.CreateInputParameter("Y2YTAMP_RATE", OdbcType.Decimal, row["Y2YTAMP_RATE"]),
                        ODBCHelper.CreateInputParameter("Y2YLB_RATE", OdbcType.Decimal, row["Y2YLB_RATE"]),
                        ODBCHelper.CreateInputParameter("Y2YUNREAD_RATE", OdbcType.Decimal, row["Y2YUNREAD_RATE"]),
                        ODBCHelper.CreateInputParameter("Y2YMODE_RATE", OdbcType.Decimal, row["Y2YMODE_RATE"]),
                        ODBCHelper.CreateInputParameter("M2MONEPASS_RATE", OdbcType.Decimal, row["M2MONEPASS_RATE"]),
                        ODBCHelper.CreateInputParameter("M2MDEVSUC_RATE", OdbcType.Decimal, row["M2MDEVSUC_RATE"]),
                        ODBCHelper.CreateInputParameter("M2MDEVEX_RATE", OdbcType.Decimal, row["M2MDEVEX_RATE"]),
                        ODBCHelper.CreateInputParameter("M2MLEX_RATE", OdbcType.Decimal, row["M2MLEX_RATE"]),
                        ODBCHelper.CreateInputParameter("M2MTAMP_RATE", OdbcType.Decimal, row["M2MTAMP_RATE"]),
                        ODBCHelper.CreateInputParameter("M2MLB_RATE", OdbcType.Decimal, row["M2MLB_RATE"]),
                        ODBCHelper.CreateInputParameter("M2MUNREAD_RATE", OdbcType.Decimal, row["M2MUNREAD_RATE"]),
                        ODBCHelper.CreateInputParameter("M2MMODE_RATE", OdbcType.Decimal, row["M2MMODE_RATE"])
                        );
                    rt = ODBCHelper.ExecuteScalar(conn, CommandType.Text, "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1");
                    if (rt != DBNull.Value)
                    {
                        row["ID"] = Convert.ToInt32(rt);
                    }
                }
            }
            return result_table;
        }
        public DataTable GetSchema()
        {
            return GetList("ID=0").Clone();
        }
    }
}
